/*
 *  Cero Project - Copyright   2006 The Cero Developement Team 
 *  (Michael Laguerre, Camille Roux, Matthieu Segret, Mathieu Sivade) 
 * 
 *  This program is free software; you can redistribute it and/or modify it 
 *  under the terms of the GNU General Public License as published by the Free 
 *  Software Foundation; either version 2 of the License, or (at your option) 
 *  any later version.
 * 
 *  This program is distributed in the hope that it will be useful, but 
 *  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 *  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
 *  for more details.
 */

package org.ceroproject.plugin;

abstract class AbstractPlugin implements Plugin {
	protected Object tryInstanciante(String name) throws NotInstantiableException {
		try {
			return ClassLoader.getSystemClassLoader().loadClass(name)
					.newInstance();
		} catch (Exception e) {
			throw new NotInstantiableException("Can't instanciate class " + name, e);
		}
	}
	
	protected Object tryInstanciante(Class type) throws NotInstantiableException {
		try {
			return type.newInstance();
		} catch (Exception e) {
			throw new NotInstantiableException("Can't instanciate class " + type, e);
		}
	}
}
